package com.jz;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.PublicKey;

/**
 * Created by Hasee on 2022-02-28.
 */
@RestController
public class RabbitController {
    @Autowired
    private AmqpTemplate amqpTemplate;

    @GetMapping("testMq")
    public String testMq(){
        amqpTemplate.convertAndSend("xiaolong","hello  xiaolong!");
        return "进行中！";
    }

    /**
     * 采购方-审批的时候
     */
    @GetMapping("shenpi")
    public ResultVo shenpi(Integer id,Integer status){
        //根据id查询出订单信息
        OrderVo orderVo = new OrderVo();
        //把单据信息发送给供应商
        amqpTemplate.convertAndSend("XiaoLongOrder",orderVo);
        //记录下单状态为=进行中
        return ResultBuilderVo.success();
    }

    @RabbitListener(queuesToDeclare = @Queue("mqResult"))
    public void mqResult(MQResultVo mqResultVo){
        //根据单号更改状态
        //完成
    }


}
